#！ /usr/bin/python3
# coding=UTF-8

def move(n,A,B,C):
    #2个盘子的情况：A->B,A->C,B->C
    if n==1:
        print('Move %s to %s'%(A,C))
    else:
        move(n-1,A,C,B)
        print('Move %s to %s' % (A,C) )
        move(n-1,B,A,C)

if __name__=='__main__':
    n= input('请输入n:')
    move(int(n),'A','B','C')